<template>
  <div class="flex-x flex-space w100">
    <div>
      {{ controlDeviceInfo.deviceParentName }}/{{ controlDeviceInfo.name }}
    </div>
    <div class="flex-x">
      <div class="flex-x" style="margin-right: 10px">
        <el-date-picker
          class="w100 dark_input"
          v-model="dataPicker"
          type="datetimerange"
          value-format="yyyy-MM-dd HH:mm:ss"
          align="right"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :default-time="['12:00:00', '08:00:00']"
          size="mini"
        >
        </el-date-picker>
      </div>

      <el-button type="primary" size="small" @click="onSubmit">搜索</el-button>
      <el-button size="small" @click="handleReset">重置</el-button>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
export default {
  computed: {
    ...mapGetters(["controlDeviceInfo"])
  },
  props: {},
  data() {
    return {
      dataPicker: []
    };
  },
  methods: {
    onSubmit() {
      console.log("object :>> ", this.dataPicker);
      // YYYY-MM-DDThh:mm:ss[.mmm]TZD
      // value-format="yyyy-MM-dd"
      if (!this.dataPicker.length) {
        this.$msg("请选择开始和结束时间");
        return;
      }
      this.$emit("onSubmit", {
        startDate: this.dataPicker[0],
        endDate: this.dataPicker[1]
      });
    },
    handleReset() {
      this.dataPicker = [];
      this.$emit("onSubmit");
    }
  }
};
</script>
<style lang="scss" scoped></style>
